import { ElMessage } from "element-plus";
import "element-plus/es/components/message/style/css";

interface ToastOptions {
	message: string;
	duration?: number;
	customClass?: string;
}

const defaultOptions = {
	duration: 2000,
	customClass: "feishu-toast",
	center: true,
	offset: 20,
};

export const showToast = (options: ToastOptions) => {
	return ElMessage({
		...defaultOptions,
		message: options.message,
		duration: options.duration || defaultOptions.duration,
		customClass: options.customClass || defaultOptions.customClass,
	});
};

export const showSuccessToast = (message: string, duration?: number) => {
	return showToast({
		message,
		duration,
		customClass: "feishu-toast feishu-toast-success",
	});
};

export const showErrorToast = (message: string, duration?: number) => {
	return showToast({
		message,
		duration,
		customClass: "feishu-toast feishu-toast-error",
	});
};
